////////////////////////////////////////////////////////////////////////////////
//
// Licensed under the MIT License
//
// Copyright (c) 2008 Chris Colinsky
// All Rights Reserved
//
// version	0.4
// http://code.google.com/p/sugarcookie/
// http://code.google.com/p/sugarcookie/wiki/License
//
////////////////////////////////////////////////////////////////////////////////

import sugarcookie.utils.RegExp;
import sugarcookie.validators.ValidationResult;

class sugarcookie.validators.ZipCodeValidator {
	public static function validate(value:Object):ValidationResult {
		//	Valid formats
		//	12345
		//	12345-6789
		
		//	Regular expression
		//	/^[0-9]{5}([-| ][0-9]{4})?/
		
		if (RegExp.match(value,"/^[0-9]{5}([-| ][0-9]{4})?/")) return new ValidationResult("Zipcode is valid",false);
		else return new ValidationResult("Zipcode format is invalid",true);
	}
}